import * as React from 'react'
import classNames from 'classnames'

import { FieldsProps, FieldsState } from './interface'

class Fields extends React.Component<FieldsProps, FieldsState> {

  static defaultProps = {
    prefixCls: 'layui-elem-field'
  }
  constructor(props: FieldsProps) {
    super(props)
    this.state = {}
  }

  render() {
    const {
      prefixCls, children, className,
      type,
      title, ...restProps
    } = this.props

    const classes = classNames(prefixCls, className, {
      [`layui-field-title`]: type == 'line'
    })

    return (
      <fieldset className={classes}>
        <legend>{title}</legend>
        <div className="layui-field-box">
          {children}
        </div>
      </fieldset>
    )
  }
}

export default Fields